package com.cyan.note.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 订单实体类
 * 对应数据库表: orders
 * 
 * @author ZhangzhenYu
 * @since 2025-01-15
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class Order extends BaseEntity {

    /**
     * 所属店铺ID
     */
    private Long shopId;

    /**
     * 订单号
     */
    private String orderNo;

    /**
     * 客户ID
     */
    private Long customerId;

    /**
     * 服务ID
     */
    private Long serviceId;

    /**
     * 订单类型
     */
    private String orderType;

    /**
     * 订单来源
     */
    private String orderSource;

    /**
     * 订单状态
     */
    private String status;

    /**
     * 支付状态
     */
    private String paymentStatus;

    /**
     * 预约日期
     */
    private LocalDate scheduledDate;

    /**
     * 预约开始时间
     */
    private LocalDateTime scheduledStartTime;

    /**
     * 预约结束时间
     */
    private LocalDateTime scheduledEndTime;

    /**
     * 实际开始时间
     */
    private LocalDateTime actualStartTime;

    /**
     * 实际结束时间
     */
    private LocalDateTime actualEndTime;

    /**
     * 实际服务时长
     */
    private BigDecimal durationHours;

    /**
     * 基础价格
     */
    private BigDecimal basePrice;

    /**
     * 订单总金额
     */
    private BigDecimal totalAmount;

    /**
     * 已付金额
     */
    private BigDecimal paidAmount;

    /**
     * 优惠金额
     */
    private BigDecimal discountAmount;

    /**
     * 附加费用
     */
    private BigDecimal additionalFee;

    /**
     * 客户备注
     */
    private String customerNotes;

    /**
     * 内部备注
     */
    private String internalNotes;

    /**
     * 取消原因
     */
    private String cancelReason;

    /**
     * 炸单原因
     */
    private String crashReason;

    /**
     * 客户评分
     */
    private Integer rating;

    /**
     * 客户评价
     */
    private String review;

    /**
     * 创建人ID
     */
    private Long createdBy;

    /**
     * 分配人ID
     */
    private Long assignedBy;

    /**
     * 分配时间
     */
    private LocalDateTime assignedAt;

    // 常量定义
    public static class OrderType {
        public static final String HOURLY = "hourly";
        public static final String FIXED = "fixed";
    }

    public static class Status {
        public static final String PENDING = "pending";
        public static final String ASSIGNED = "assigned";
        public static final String IN_PROGRESS = "in_progress";
        public static final String COMPLETED = "completed";
        public static final String PAID = "paid";
        public static final String CANCELLED = "cancelled";
        public static final String CRASHED = "crashed";
    }

    public static class PaymentStatus {
        public static final String UNPAID = "unpaid";
        public static final String PARTIAL = "partial";
        public static final String PAID = "paid";
        public static final String REFUNDED = "refunded";
    }

    public static class OrderSource {
        public static final String MANUAL = "manual";
        public static final String WECHAT_MINIPROGRAM = "wechat_miniprogram";
        public static final String H5_WEBSITE = "h5_website";
        public static final String MANAGER_MANUAL = "manager_manual";
    }
}